package com.neuedu.studentmanage.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.neuedu.studentmanage.entity.Pager;
import com.neuedu.studentmanage.entity.Result;
import com.neuedu.studentmanage.entity.Teacher;
import com.neuedu.studentmanage.mapper.TeacherMapper;
import com.neuedu.studentmanage.service.TeacherService;

@Service
@Transactional
public class TeacherServiceImpl implements TeacherService {

	@Autowired
	private TeacherMapper teacherMapper;

	@Override
	public List<Teacher> findListByPager(Pager<Teacher> pager) {
		return teacherMapper.findListByPager(pager);
	}

	@Override
	public Integer findTotalByPager(Pager<Teacher> pager) {
		return teacherMapper.findTotalByPager(pager);
	}

	@Override
	public Result add(Teacher object) {
		Result result = new Result(false, "新增老师信息失败！");
		boolean ret = teacherMapper.add(object);
		if (ret) {
			result = new Result(true, "新增老师信息成功！");
		}
		return result;
	}

	@Override
	public Result edit(Teacher object) {
		Result result = new Result(false, "修改老师信息失败！");
		boolean ret = teacherMapper.edit(object);
		if (ret) {
			result = new Result(true, "修改老师信息成功！");
		}
		return result;
	}

	@Override
	public Result deleteByIds(List<Teacher> ids) {
		Result result = new Result(false, "删除老师信息失败！");
		boolean ret = teacherMapper.deleteByIds(ids);
		if (ret) {
			result = new Result(true, "删除老师信息成功！");
		}
		return result;
	}

	@Override
	public List<Teacher> findAll() {
		return teacherMapper.findAll();
	}

	@Override
	public Teacher login(Teacher teacher) {
		return teacherMapper.login(teacher);
	}

	@Override
	public List<Teacher> findBy(Teacher teacher) {
		return teacherMapper.findBy(teacher);
	}

	@Override
	public Result passEdit(Teacher teacher) {
		Result result = new Result(false, "修改个人密码失败！");
		boolean ret = teacherMapper.passEdit(teacher);
		if (ret) {
			result = new Result(true, "修改个人密码成功！");
		}
		return result;
	}

}
